const path = require('path')
// html 文件重新生成
const htmlWepackPlugin = require('html-webpack-plugin')
// 文件清理
const cleanWebpackPlugin = require('clean-webpack-plugin')
// 引入 webpack
const webpack = require('webpack')

module.exports = {
    entry: { //多入口
        app: './src/index.js',
        print: './src/print.js'
    },
    devtool: 'inline-source-map', // 代码调试使用，仅限于开发阶段
    devServer: {
        contentBase: './dist' // 指定文件变化的路径
    },
    plugins: [
        new cleanWebpackPlugin(['dist']), // 参数为需要清理的文件夹
        new htmlWepackPlugin({
            title: '模块热替换'
        }),
        new webpack.NamedModulesPlugin(),
        new webpack.HotModuleReplacementPlugin()
    ],
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].bundle.js', //输出根据entry定义的名称来输出
        publicPath: '/' //
    }
}